﻿
namespace Util.Common
{
    /// <summary>
    /// 正则表达式工具类
    /// </summary>
    /// 源自uoLib.Common.RegexPatterns
    /// <see cref="http://udnz.com/Works/uolib/"/>
    public static class UtilRegex
    {
        public const string Email = @"^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$";
        public const string FileName = @"^[^\\\./:\*\?\""<>\|]{1}[^\\/:\*\?\""<>\|]{0,254}$";
        public const string FolderName = @"^[^\\\/\?\*\""\>\<\:\|]*$";
        public const string HtmlColor = "^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$";
        public const string HtmlTag = "<[^>]+>";
        public const string IPv4 = @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$";
        public const string MobileNum = @"(\+?86)?1[3|5|8][\d]{9}\b";
        public const string URI = @"^(https|http|ftp|rtsp|mms)?://((([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+)@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|[^`~!@#$%\^&*\\(\)=\+_\[\]{}\|;:\.'"",<>/\?]+|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-/]+)+)$";
        public const string URL = @"^(https|http)?://((([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+)@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|[^`~!@#$%\^&*\\(\)=\+_\[\]{}\|;:\.'"",<>/\?]+|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-/]+)+)$";
    }
}
